<template>
    <require from="./em-project-edit-module.less"></require>
    <div class="em-project-edit-module">
        <div class="ui form">
            <div class="fields">
                <div class="four wide field">
                    <label>名称</label>
                    <input type="text" value.bind="name" placeholder="名称">
                </div>
                <div class="four wide field">
                    <label>描述</label>
                    <input type="text" value.bind="desc" placeholder="描述">
                </div>
                <div class="four wide field">
                    <label>模块负责人</label>
                    <em-dropdown classes="search selection" label="name" value="username" items.bind="users" selected.bind="leader"></em-dropdown>
                </div>
                <div class="four wide field">
                    <label>默认经办人</label>
                    <em-dropdown classes="search selection" label="name" value="username" items.bind="users" selected.bind="operator"></em-dropdown>
                </div>
                <div class="two wide field">
                    <label style="visibility: hidden;">添加</label>
                    <div click.delegate="addHandler()" class="ui icon blue circular button" title="添加模块"><i class="plus icon"></i></div>
                </div>
            </div>
        </div>
        <div class="ui divider"></div>
        <table class="ui table">
            <thead>
                <tr>
                    <th>名称</th>
                    <th>描述</th>
                    <th>模块负责人</th>
                    <th>默认经办人</th>
                    <th class="right aligned">操作</th>
                </tr>
            </thead>
            <tbody>
                <tr repeat.for="item of modules">
                    <td>
                        <em-editable-input value.bind="item.name" onok.call="editNameOkHandler($event, item)"></em-editable-input>
                    </td>
                    <td>
                        <em-editable-input value.bind="item.description" onok.call="editDescOkHandler($event, item)"></em-editable-input>
                    </td>
                    <td>
                        <em-editable-dropdown label="name" value="username" items.bind="users" selected.bind="item.leader.username" onok.call="editLeaderHandler($event, item)"></em-editable-dropdown>
                    </td>
                    <td>
                        <em-editable-dropdown label="name" value="username" items.bind="users" selected.bind="item.operator.username" onok.call="editOperatorHandler($event, item)"></em-editable-dropdown>
                    </td>
                    <td class="right aligned">
                        <div class="ui horizontal bulleted list">
                            <a style="color: red;" ui-dropdown-action class="ui icon top right pointing dropdown item" title="删除状态">
                                删除
                                <div class="menu">
                                    <div style="color: red;" class="item" click.delegate="delHandler(item)"><i class="trash red outline icon"></i>确认删除</div>
                                </div>
                            </a>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>
